<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<head>
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<link rel="stylesheet" href="./css/flipclock.css">
	<link rel="stylesheet" href="./css/style.css">

	<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->

	<script src="./js/jquery.min.js"></script>
	<script src="./js/flipclock.js"></script>
	<script src="./js/ip.js"></script>
</head>

<body>

	<div id="box">
		<div id="content">
			<div class="clock" id="flipclock"></div>
			<h1 class="date" id='ShowDate'></h1>
			<div id="mask"></div>
			<span id="ip" style="color: rgba(255, 255, 255, 0.5); font-size: 1em;"></span>
		</div>
	</div>

	<script type="text/javascript">
		// mobile
		// if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
		// 	document.getElementById('flipclock').setAttribute("style","zoom:1.5;");
		// 	document.getElementById('ShowDate').setAttribute("style","zoom:1.5;");
		// }
		document.getElementById('flipclock').setAttribute("style", "zoom:4.7;");
		document.getElementById('ShowDate').setAttribute("style", "zoom:4.7;");

		var clock;

		$(document).ready(function () {
			clock = $('.clock').FlipClock({
				// clockFace: 'TwelveHourClock',
				clockFace: 'TwentyFourHourClock',
				showSeconds: false
			});
		});

		function refresh() {
			console.log("refresh");
			setInterval(refresh, 1000 * 60)

			setDate()
			
			// chrome://flags/
			// #enable-webrtc-hide-local-ips-with-mdns disable
			getIP(setIp)
		}

		function setIp(ip) {
			document.getElementById("ip").innerText = ip
		}

		function setDate() {
			var month = ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'June', 'Jul.', 'Aug.', 'Sept.', 'Oct.', 'Nov.', 'Dec.'];
			var week = ['Sun.', 'Mon.', 'Tues.', 'Wed.', 'Thur.', 'Fri.', 'Sat.'];
			var d = new Date();
			// document.getElementById('ShowDate').innerHTML = d.getFullYear() + "年" +(d.getMonth() + 1) + "月" + d.getDate() + "日" + ' 星期'+'日一二三四五六'.charAt(new Date().getDay());
			document.getElementById('ShowDate').innerHTML = week[d.getDay()] + " " + month[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
		}

		refresh()
	</script>

</body>

</html>